home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: October 30, 1998
- //
- // Description:
- //
- // An option window used to create a named displayLayer.
- // A displayLayer is a grouping of DAG objects used to control drawing.
- //
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // Display layer base index
- //
- if ($forceFactorySettings || !`optionVar -exists displayLayerBase`) {
- optionVar -intValue displayLayerBase 1;
- }
-
- // Set to Current flag
- //
- if ($forceFactorySettings || !`optionVar -exists displayLayerCurrent`) {
- optionVar -intValue displayLayerCurrent false;
- }
-
- // Contents flag
- //
- if ($forceFactorySettings || !`optionVar -exists displayLayerContents`) {
- optionVar -intValue displayLayerContents 1;
- }
- }
-
- //
- // Procedure Name:
- // createDisplayLayerSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc createDisplayLayerSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
-
- // Layer name
- textFieldGrp -e -text "layer1" displayLayerNameWidget;
-
- // Base layer index
- int $base = `optionVar -q displayLayerBase`;
- intFieldGrp -e -v1 $base displayLayerBaseWidget;
-
- // Contents flag
- int $contents = `optionVar -q displayLayerContents`;
- radioButtonGrp -e -sl $contents contentsRadio;
-
- // Set to Current flag
- int $current = `optionVar -q displayLayerCurrent`;
- checkBoxGrp -e -v1 $current currentCheck;
-
- setParent $parent;
- }
-
- //
- // Procedure Name:
- // createDisplayLayerCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc createDisplayLayerCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Contents flag
- //
- optionVar -iv displayLayerContents `radioButtonGrp -q -sl contentsRadio`;
-
- // 'Make current' flag
- //
- optionVar -iv displayLayerCurrent `checkBoxGrp -q -v1 currentCheck`;
-
- // Base layer index
- //
- optionVar -iv displayLayerBase `intFieldGrp -q -v1 displayLayerBaseWidget`;
-
- if ($doIt) {
- performCreateDisplayLayer 0;
- addToRecentCommandQueue "performCreateDisplayLayer 0" "CreateDisplayLayer";
- }
- }
-
- //
- // Procedure Name:
- // createDisplayLayerOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc createDisplayLayerOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "createDisplayLayer";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -tabsVisible 0 -scrollable 1;
- string $parent = `columnLayout -adjustableColumn 1`;
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- // displayLayer name
- //
- textFieldGrp
- -label "Name"
- displayLayerNameWidget;
-
- // displayLayer number
- //
- intFieldGrp
- -label "Number"
- displayLayerBaseWidget;
-
- // Current layer setting option
- //
- checkBoxGrp -numberOfCheckBoxes 1
- -label1 "Make the created display layer current"
- currentCheck;
-
- // Which items to add to the layer
- //
- radioButtonGrp -nrb 3
- -cw 2 80
- -cw 4 160
- -l "Add to new display layer"
- -la3 "Nothing" "Selected" "Selected and Children"
- -sl (`optionVar -q displayLayerContents`)
- -cc1 "optionVar -iv displayLayerContents 1"
- -cc2 "optionVar -iv displayLayerContents 2"
- -cc3 "optionVar -iv displayLayerContents 3"
- contentsRadio;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Create"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Display Layer Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // createDisplayLayerHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string createDisplayLayerHelp()
- {
-
- return
- " Command: Create Display Layer - create a displayLayer.\n" +
- "Selection: Selected DAG objects are added to the displayLayer.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd;
-
- setOptionVars(false);
-
- // get the displayLayer name
- string $displayLayerName = "layer1";
- if (`textFieldGrp -exists displayLayerNameWidget`) {
- $displayLayerName = `textFieldGrp -q -text displayLayerNameWidget`;
- }
-
- // get the displayLayer base number
- int $displayLayerBase = `optionVar -q displayLayerBase`;
-
- // create the displayLayer command string
- if (0 == size($displayLayerName)) {
- $displayLayerName = "layer1";
- }
- $displayLayerName = "\"" + $displayLayerName + "\"";
- $cmd = "createDisplayLayer -name " + $displayLayerName
- + " -number " + $displayLayerBase;
-
- int $contents = `optionVar -q displayLayerContents`;
- int $current = `optionVar -q displayLayerCurrent`;
- if( $contents == 1 )
- {
- $cmd += " -empty";
- }
- else if( $contents == 2 )
- {
- $cmd += " -nr";
- }
- if( $current ) $cmd += " -mc";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performCreateDisplayLayer
- //
- // Description:
- // Perform the create display layer command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the createDisplayLayer command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- global proc string performCreateDisplayLayer(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
-
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- createDisplayLayerOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-